<?php

/*
	Class: PagepartsPages

	About: Author
		Rich Joslin

	About: License
		<http://communit.as/docs/license>

	About: See Also
		- <Cts_Db_Table_Abstract>
*/
class PagepartsPages extends Cts_Db_Table_Abstract {

	/* Group: Instance Variables */

	/*
		Variable: $_name
	*/
	protected $_name = 'pageparts_pages';

	/*
		Variable: $_primary
	*/
	protected $_primary = 'id';

	/* Group: Properties */

	/*
		Property: $_keyword_search_field_names
	*/
	public $_keyword_search_field_names = array("title");

	/* Group: Instance Methods */

	/*
		Function: getBulk

		Arguments:
			ids - An array of IDs.

		Returns: array of row data or an empty array
	*/
	function getBulk(array $ids) {
		$where = "id in (0";
		foreach ($ids as $id) {
			$where .= ", ".$id;
		}
		$where .= ")";
		// $where should end up looking like this:
		// id in (0, 4, 23, 6, 324)
		$tmp_rows = $this->fetchAll($where);
		if (!is_null($tmp_rows)) {
			return $tmp_rows->toArray();
		} else {
			return array();
		}
	}

	/*
		Function: deleteBulk
			Deletes multiple records at once.

		Arguments:
			ids - An array of IDs.

		Returns: boolean
	*/
	function deleteBulk($ids) {
		$where = "id in ('0'";
		foreach ($ids as $id) {
			$where .= ", ".$id;
		}
		$where .= ")";
		// $where should end up looking like this:
		// id in (0, 4, 23, 6, 324)
		$rowsdeleted = $this->delete($where);
		if ($rowsdeleted >= 1) {
			return true;
		} else {
			return false;
		}
	}

	/*
		Function: deleteDependents
			Deletes all the page parts and other children for a given page.
	*/
	function deleteDependents($page_id) {
		// TODO - this
	}

}
